using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using QLKS.HeThongBUS;
using DevComponents.DotNetBar;

namespace QLKS
{
    public partial class TraCuuHD : DevComponents.DotNetBar.Office2007Form
    {
        public TraCuuHD()
        {
            InitializeComponent();
        }

        private void TraCuuHD_Load(object sender, EventArgs e)
        {
            HienThi();
            txtngay.Text = DateTime.Now.ToShortDateString();
        }

        void HienThi()
        {
            DataTable dt = HD_BUS.DSHoaDon();
            grvdsp.DataSource = dt ;
        }
       


        private void ckboxngay_CheckedChanged(object sender, EventArgs e)
        {

            if (ckboxngay.Checked == true)
            {
                txtngay.Enabled = true;
            }
            else if (ckboxngay.Checked == false)
            {
                txtngay.Enabled = false;
            }


        }

        private void ckboxsp_CheckedChanged(object sender, EventArgs e)
        {
            if (ckboxsp.Checked == true)
            {
                txtsp.Enabled = true;
            }
            else if (ckboxsp.Checked == false)
            {
                txtsp.Enabled = false;
            }
        }

        private void ckboxkdk_CheckedChanged(object sender, EventArgs e)
        {
            if (ckboxkdk.Checked == true)
            {
                txtkdk.Enabled = true;
            }
            else if (ckboxkdk.Checked == false)
            {
                txtkdk.Enabled = false;
            }
        }
        #region Timkiem
        string dk1;
        string dk2;
        string dk3;
        



        

        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (txtkdk.Text != "" && ckboxkdk.Checked == true)
            {
                dk1 = " And KhachHang.TenKhachHang LIKE  '%" + txtkdk.Text.ToString() + "%'";
            }
            if (txtkdk.Text == "" || ckboxkdk.Checked == false)
            {
                dk1 = "";
            }
            if (txtsp.Text == "" || ckboxsp.Checked == true)
            {
                dk2 = " And CTThuePhong.MaPhong LIKE '" + txtsp.Text.ToString() + "'";

            }
            if (txtsp.Text == "" || ckboxsp.Checked == false)
            {
                dk2 = "";
            }
            if (ckboxngay.Checked == true)
            {
                dk3 = " And CTThuePhong.NgayTraPhong LIKE '" + DateTime.Now.ToShortDateString() + "'";

            }
            if (ckboxngay.Checked == false)
            {
                dk3 = "";
            }
            DataTable dt = HD_BUS.TraCuuHoaDon(dk1, dk2, dk3);
            grvdsp.DataSource = dt;
            if (dt.Rows.Count == 0)
            {
                MessageBoxEx.Show("Không tìm thấy dữ liệu theo yêu cầu", "Thông báo");
            }
        }
        #endregion
        private void btnthoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}